Skip to content

db: add AtomicContext#4724

Merged
algorandskiy merged 4 commits into
algorand:masterfrom
algorandskiy:pavel/atomic-context
Nov 2, 2022
Merged

db: add AtomicContext#4724
algorandskiy merged 4 commits into
algorand:masterfrom
algorandskiy:pavel/atomic-context

Conversation

@algorandskiy
Copy link
Copy Markdown
Contributor

Summary

Atomic() doesn't accept a context, but always passes context.Background() to the callback fn.

This PR adds AtomicContext() that does accept a context and passes it to its callback.

Replaces #4104

@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 1, 2022

Codecov Report

Merging #4724 (5bc707a) into master (a8f1b4a) will decrease coverage by 0.64%.
The diff coverage is 80.00%.

@@            Coverage Diff             @@
##           master    #4724      +/-   ##
==========================================
- Coverage   54.61%   53.96%   -0.65%     
==========================================
  Files         414      414              
  Lines       53516    53515       -1     
==========================================
- Hits        29228    28881     -347     
- Misses      21864    22199     +335     
- Partials     2424     2435      +11     
Impacted Files Coverage Δ
ledger/catchpointtracker.go 56.50% <75.00%> (-4.09%) ⬇️
util/db/dbutil.go 42.26% <100.00%> (-0.35%) ⬇️
crypto/onetimesig.go 0.00% <0.00%> (-76.07%) ⬇️
data/bookkeeping/txn_merkle.go 62.96% <0.00%> (-22.23%) ⬇️
data/account/participation.go 45.68% <0.00%> (-18.11%) ⬇️
crypto/rand.go 11.76% <0.00%> (-17.65%) ⬇️
data/transactions/logic/sourcemap.go 82.75% <0.00%> (-17.25%) ⬇️
stateproof/verify/stateproof.go 64.28% <0.00%> (-11.43%) ⬇️
ledger/internal/eval.go 39.35% <0.00%> (-9.64%) ⬇️
crypto/curve25519.go 56.36% <0.00%> (-5.46%) ⬇️
... and 26 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Copy Markdown
Contributor

@brianolson brianolson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good simple change except I don't like the dbCtx -> ctx rename

Comment thread ledger/catchpointtracker.go Outdated
start := time.Now()
ledgerGeneratecatchpointCount.Inc(nil)
err := ct.dbs.Rdb.Atomic(func(dbCtx context.Context, tx *sql.Tx) (err error) {
err := ct.dbs.Rdb.AtomicContext(ctx, func(ctx context.Context, tx *sql.Tx) (err error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is less clear because it shadows the outer function's param ctx

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, fixed!

@algorandskiy algorandskiy merged commit 561bc4a into algorand:master Nov 2, 2022
@algorandskiy algorandskiy deleted the pavel/atomic-context branch March 16, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants